package com.achilles.bean;

import android.text.TextUtils;

/**
 * Created by AchillesL on 2016-9-20.
 */
public class ProjectBean extends DataBean{
    private String projectName;                       //任务名
    private String projectNote;                       //备注
    private boolean projectFixNote;                  //是否固定备注
    private ProjectType projectType;                  //任务类型（单次，日，周，月）
    private int projectScore;                        //任务积分
    private String projectCreateTime;               //任务创建时间
    private String projectCompleteDate;             //任务完成时间
    private String projectCompleteSpecificTime;    //任务完成时间
    private int projectOrder;                       //任务序号
    private int projectTotalTimes;                  //任务进行总次数
    private int projectTimes;                       //任务进行当前次数

    private String otherInfo;                       //其他信息

    public enum ProjectType {
        Single,EveryDay,EveryWeek,EveryMonth,Normal
    }

    public ProjectBean() {
    }

    public ProjectBean(String projectName, String projectNote, boolean projectFixNote,
                       ProjectType projectType, int projectScore, String projectCreateTime,
                       String projectCompleteDate, String projectCompleteSpecificTime, int
                               projectOrder, int projectTotalTimes, int projectTimes, String
                               otherInfo) {
        this.projectName = projectName;
        this.projectNote = projectNote;
        this.projectFixNote = projectFixNote;
        this.projectType = projectType;
        this.projectScore = projectScore;
        this.projectCreateTime = projectCreateTime;
        this.projectCompleteDate = projectCompleteDate;
        this.projectCompleteSpecificTime = projectCompleteSpecificTime;
        this.projectOrder = projectOrder;
        this.projectTotalTimes = projectTotalTimes;
        this.projectTimes = projectTimes;
        this.otherInfo = otherInfo;
    }

    public boolean isProjectFixNote() {
        return projectFixNote;
    }

    public void setProjectFixNote(boolean projectFixNote) {
        this.projectFixNote = projectFixNote;
    }

    public String getProjectCompleteSpecificTime() {
        return projectCompleteSpecificTime;
    }

    public void setProjectCompleteSpecificTime(String projectCompleteSpecificTime) {
        this.projectCompleteSpecificTime = projectCompleteSpecificTime;
    }

    public String getOtherInfo() {
        return otherInfo;
    }

    public void setOtherInfo(String otherInfo) {
        this.otherInfo = otherInfo;
    }

    public String getProjectNote() {
        return projectNote;
    }

    public void setProjectNote(String projectNote) {
        this.projectNote = projectNote;
    }

    public boolean isCompleted() {
        if (projectType == ProjectType.Single) {
            return !TextUtils.isEmpty(projectCompleteDate);
        }else {
            return projectTotalTimes <= projectTimes;
        }
    }

    public int getProjectTotalTimes() {
        return projectTotalTimes;
    }

    public void setProjectTotalTimes(int projectTotalTimes) {
        this.projectTotalTimes = projectTotalTimes;
    }

    public int getProjectTimes() {
        return projectTimes;
    }

    public void setProjectTimes(int projectTimes) {
        this.projectTimes = projectTimes;
    }

    public int getProjectOrder() {
        return projectOrder;
    }

    public void setProjectOrder(int projectOrder) {
        this.projectOrder = projectOrder;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public ProjectType getProjectType() {
        return projectType;
    }

    public void setProjectType(ProjectType projectType) {
        this.projectType = projectType;
    }

    public int getProjectScore() {
        return projectScore;
    }

    public void setProjectScore(int projectScore) {
        this.projectScore = projectScore;
    }

    public String getProjectCreateTime() {
        return projectCreateTime;
    }

    public void setProjectCreateTime(String projectCreateTime) {
        this.projectCreateTime = projectCreateTime;
    }

    public String getProjectCompleteDate() {
        return projectCompleteDate;
    }

    public void setProjectCompleteDate(String projectCompleteDate) {
        this.projectCompleteDate = projectCompleteDate;
    }

    @Override
    public int hashCode() {
        return projectCreateTime.hashCode();
    }

    @Override
    public boolean equals(Object o) {
        boolean isProjectBean = o instanceof ProjectBean;
        if (!isProjectBean) return false;
        else {
            ProjectBean projectBean = (ProjectBean) o;
            return projectBean.getProjectCreateTime().equals(this.getProjectCreateTime());
        }
    }

    public int getNormalProjectValueHashCode() {
        return (this.getProjectName() + this.getProjectCreateTime() + this
                .getProjectTotalTimes() + this.getProjectScore()).hashCode();
    }

    @Override
    public String toString() {
        return "projectName: " + projectName + " projectType: " + projectType + " projectScore: "
                + projectScore + " projectCreateTime: " + projectCreateTime + " " +
                "projectCompleteDate: " + projectCompleteDate + " projectOrder: " + projectOrder;
    }

}
